﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.SessionState;

namespace VideoTag.Service
{
    /// <summary>
    /// Summary description for vcode
    /// </summary>
    public class vcode : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {

            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            string myVcode = Puman.VCode.GenerateCheckCode(4, 5, out ms);
            context.Session["vcode"] = myVcode;
            Image image = new Bitmap(ms);

            image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

            context.Response.ClearContent();

            context.Response.ContentType = "image/Jpeg";

            context.Response.BinaryWrite(ms.ToArray());

            image.Dispose();

        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}